///**
// * web2010_admin
// * cn.aresoft.web.interceptor AdminInterceptor.java
// */
//package cn.aresoft.web.interceptor;
//
//import java.util.Date;
//import java.util.HashMap;
//import java.util.Map;
//
//import cn.aresoft.framework.exception.LimitOfAuthorityException;
//import cn.aresoft.framework.service.AuthorityService;
//import cn.aresoft.logic.model.sys.ModuleRef;
//import cn.aresoft.logic.model.sys.User;
//
//import com.opensymphony.xwork2.ActionInvocation;
//import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
//
///**
// * @author Jerry 2010-8-19 下午05:02:36
// */
//public class AdminInterceptor extends AbstractInterceptor {
//
//	/*
//	 * (non-Javadoc)
//	 * 
//	 * @see
//	 * com.opensymphony.xwork2.interceptor.AbstractInterceptor#intercept(com
//	 * .opensymphony.xwork2.ActionInvocation)
//	 */
//	@Override
//	public String intercept(ActionInvocation arg0) throws Exception {
//		// TODO Auto-generated method stub
//		System.out.println("Action Class:"
//				+ arg0.getAction().getClass().getSimpleName());
//		System.out.println("Invocation Context:"
//				+ arg0.getInvocationContext().getName());
//		String forword = "";
//		Map session = arg0.getInvocationContext().getSession();
//		if (session.get("user") == null) {
//			return "login";
//		}
//		User user = (User) session.get("user");
//		HashMap<Long, ModuleRef> userLimits = (HashMap<Long, ModuleRef>) session
//				.get("limits");
//		Object action = arg0.getAction();
//		if (action instanceof UserAware) {
//			((UserAware) action).setUser(user);
//			if (!user.isRoot()) {
//				if (userLimits == null || userLimits.size() == 0) {
//					throw new LimitOfAuthorityException("没有权限");
//				}
//				((UserAware) action).setUserLimits(userLimits);
//			}
//		}
//		if (action instanceof ServiceAware) {
//			AuthorityService service = ((ServiceAware) action)
//					.getModuleService();
//			service.setOperationUser(user);
//			String operationName = arg0.getInvocationContext().getName()
//					.toLowerCase();
////			if (((ServiceAware) action).getVo() != null) {
////				if ("insert".equals(operationName)) {
////					((ServiceAware) action).getVo().getBase().setCreateTime(new Date());
////					((ServiceAware) action).getVo().getBase().setCreateUser(user.getId());
////				} else {
////					((ServiceAware) action).getVo().getBase().setLastModTime(
////							new Date());
////					((ServiceAware) action).getVo().getBase().setModUser(
////							user.getId());
////				}
////			}
//			// service.setModuleFunction(((ServiceAware)
//			// action).getModuleFunction());
//			service.setUserLimits(userLimits);
//			if (!service.validateLimit(user, operationName)) {
//				throw new LimitOfAuthorityException("没有权限");
//			}
//		}
//		return arg0.invoke();
//	}
//
//}
